package ZorkObjects;

import java.util.ArrayList;
import java.util.HashMap;

public class Attack 
{
    private ArrayList<String> actions;
    private Condition condition;
    private String print;

    public Attack(HashMap configMap) 
    {
        actions = new ArrayList<String>();

        if(configMap != null)
        {
            print = (String)configMap.remove("print");
            condition = new Condition((HashMap)configMap.remove("condition"));

            Object actionContainer = configMap.remove("action");
            if(actionContainer instanceof ArrayList) 
            {
                for(String action : (ArrayList<String>)actionContainer) {
                    actions.add(action);
                }
            }
            else if(actionContainer instanceof String)
            {
                actions.add((String)actionContainer);
            }
            else {
                System.out.println("this should never happen attack");
            }
        }
    }

	public ArrayList<String> getActions() {
		return actions;
	}

	public Condition getCondition() {
		return condition;
	}

	public String getPrint() {
		return print;
	}

    public String toString()
    {
        String toReturn = "";

        toReturn += condition.toString();
        toReturn += "\nactions = ";
        toReturn += actions.toString();
        toReturn += "\nprint =";
        toReturn += print;
        
        return toReturn;
    }
}
